﻿//--------------------------------------------------------------------------
//
//  File:        LabelControl.cs
//
//  Coder:       bigeagle@gmail.com
//
//  Date:        2013/2/18
//
//  Description: 标签控件类
//  
//  History:     2013/2/28 created by bigeagle  
//
//--------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// “用户控件”项模板在 http://go.microsoft.com/fwlink/?LinkId=234236 上提供

namespace Bigeagle.Metro.Games.Controls
{
    /// <summary>
    /// 标签控件类
    /// </summary>
    public sealed partial class LabelControl : UserControl
    {
        #region 标签文本属性
        public static readonly DependencyProperty TextProperty =
            DependencyProperty.Register("Text", typeof(string), typeof(LabelControl)
            , new PropertyMetadata("a", new PropertyChangedCallback(OnTextChanged)));

        public string Text
        {
            get
            {
                return (string)GetValue(TextProperty);
            }
            set
            {
                SetValue(TextProperty, value);
            }
        }
        private static void OnTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            LabelControl control = (LabelControl)d;
            control.tbName.Text = (string)e.NewValue;

        }
        #endregion//end 标签文本属性

        #region 标签背景属性
        public static readonly DependencyProperty LabelBackgroundProperty =
            DependencyProperty.Register("LabelBackground", typeof(Brush), typeof(LabelControl)
            , new PropertyMetadata(new SolidColorBrush(Color.FromArgb(0, 243, 225, 43))
                , new PropertyChangedCallback(OnLabelBackgroundChanged)));

        public Brush LabelBackground
        {
            get
            {
                return (Brush)GetValue(LabelBackgroundProperty);
            }
            set
            {
                SetValue(LabelBackgroundProperty, value);
            }
        }
        private static void OnLabelBackgroundChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            LabelControl control = (LabelControl)d;
            control.epBackground.Fill = e.NewValue as Brush;
        }

        #endregion//end 棋盘背景属性

        public LabelControl()
        {
            this.InitializeComponent();
        }
    }//end class
}//end namespace
